// ./config/webpack.prod.js
const merge = require('webpack-merge');
const common = require('./webpack.base.js');

const path = require('path');
// 加载插件
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

function joinPath(filepath) {
    return path.join(__dirname, filepath);
}

module.exports = merge(common, {
    mode: 'production',
    devtool: 'source-map', // cheap-module-source-map
    entry: {
        main: [joinPath('../src/main.js')]
    },
    output: {
        filename: '[name].js?v=[chunkhash]',
        chunkFilename: '[id].js?v=[chunkhash]'
    },
    plugins: [
        new CleanWebpackPlugin(),
    ],
});
